﻿@{
    ViewBag.Title = "修改图书类型";
    Layout = "~/Views/Shared/_Layout.cshtml";
    BookType BookType = ViewBag.BookType;
}
@using Model;
<script>
    $(function () {
        $("[href='/BooksManage/BookType']").parent("li").addClass("active").parent().parent("div").addClass("collapse in").parent("li").addClass("active");

    });
</script>
<div class="card">
    <form id="EditBookType" class="form-horizontal" method="post" novalidate="novalidate">
        <input type="hidden" value="@BookType.TypeID" name="TypeID" />
        <div class="content">
            <legend>编写信息</legend>

            <fieldset>
                <div class="form-group">
                    <label class="col-sm-2 control-label">图书类型名称</label>
                    <div class="col-sm-6" style="width: 300px">
                        <input class="form-control" type="text" name="TypeName" required="required" aria-required="true" value="@BookType.TypeName">
                    </div>
                    <div class="col-sm-4" id="required"><code>请输入1-50字的名称</code></div>

                </div>
            </fieldset>

            <fieldset>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状  态</label>
                    <div class="col-sm-6" style="width: 300px">
                        <div class="btn-group bootstrap-select">
                            <select name="State" class="selectpicker" data-title="请选择" data-style="btn-default btn-block" data-menu-style="dropdown-blue" tabindex="-98" size="5">
                                @if (BookType.State == 0)
                                {
                                    <option value="0" selected="selected">可使用</option>
                                    <option value="1">不可用</option>
                                }
                                else
                                {
                                    <option value="0">可使用</option>
                                    <option value="1" selected="selected">不可用</option>
                                }
                            </select>
                        </div>
                    </div>
                    @*<div class="col-sm-4"><code>required</code></div>*@
                </div>
            </fieldset>
        </div>

    </form>
    <div class="footer text-center">
        <button id="submit" type="button" class="btn btn-info btn-fill" onclick="showSwal('submit')">保存 </button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button id="cloes" type="button" class="btn btn-info btn-fill" onclick="location.href='/BooksManage/BookType'">返回 </button>
    </div>
</div>

<script>
    $(function () {
    });
    //提交表单
    function showSwal(type) {
        if (type == 'submit') {
            swal({
                title: "确定提交吗?",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false
            }, function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        cache: true,
                        type: "POST",
                        url: '/BooksManage/EditBookType',
                        data: $('#EditBookType').serialize(),// 你的formid
                        async: false,
                        error: function (request) {
                        },
                        success: function (data) {
                            if (data == "保存成功") {
                                swal(data, "", "success");
                            } else {
                                swal(data, "", "error");
                            }

                        }
                    });
                } else {
                    swal("取消保存", "", "error");
                }
            });
        }
    }
</script>
